﻿<UserControl x:Class="Lights.Controls.SelectionControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             Name="selectionControl"
             xmlns:local="clr-namespace:Lights.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="200" d:DesignWidth="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="541*"/>
            <ColumnDefinition Width="59*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="Selezionate "/>
            <TextBlock Text="{Binding ElementName=panel,Path=ItemsSource.Count}"/>
            <TextBlock Text=" foto"/>
        </StackPanel>
        <Border
            BorderBrush="Black"
            BorderThickness="1"
            Grid.Row="1"
            Grid.ColumnSpan="3">
        <ListView x:Name="panel"
            Margin="3"
            ItemsSource="{Binding ElementName=selectionControl,Path=ItemsSource}"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            ScrollViewer.IsDeferredScrollingEnabled="True"
            SelectionChanged="panel_SelectionChanged" >

            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True" VirtualizingPanel.VirtualizationMode="Recycling" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid MaxWidth="80" MaxHeight="80" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="20"/>
                        </Grid.RowDefinitions>
                        <Image Margin="12" Source="{Binding Thumbnail}" />
                        <TextBlock HorizontalAlignment="Center" Grid.Row="1" Text="{Binding Name}" Tag="{Binding Hashcode}" />
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        </Border>
        <Button x:Name="cmdAddNewList" Grid.Column="3" Grid.Row="1" Margin="3" Click="cmdAddNewList_Click" >
            <TextBlock Text="Crea nuova lista">
                <TextBlock.LayoutTransform>
                    <RotateTransform Angle="90" />
                </TextBlock.LayoutTransform>
            </TextBlock>
        </Button>
    </Grid>
</UserControl>
